using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Webcar.BLL;
using ToolsLayer;
using BusinessEntity;

namespace Webcar.Controls.View
{
    public partial class DriverInfoView : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void InitDriverInfo(string driverid)
        {
            DriverBLL db = new DriverBLL();
            BS_EMPEntity user = db.GetUserInfo(driverid);

            PropertyBindings pb = new PropertyBindings();
            pb.EntityObject = user;
            this.SetBindRelations(pb);
            pb.SetBindingObjectValue();

            string sql = "select * from v_bs_emp where man_code=@driverid";
            IDataParameter p = DB.helper.GetParameter("@driverid", driverid);

            DataSet ds = DB.ExecuteDataset(sql, p);
            this.lblJobKind.Text = ds.Tables[0].Rows[0]["job_name"].ToString();
            this.lblDept.Text = ds.Tables[0].Rows[0]["dept_name"].ToString();
            this.lblChildDept.Text = ds.Tables[0].Rows[0]["child_dept_name"].ToString();
            this.lblEducation.Text = ds.Tables[0].Rows[0]["edcation_name"].ToString();
            this.lblSex.Text = ds.Tables[0].Rows[0]["sex"].ToString();
            this.lblClassLevel.Text = ds.Tables[0].Rows[0]["class_level_name"].ToString();
            InfoChecker ic = new InfoChecker();
            ic.SetInfoReaded(driverid, InfoCheckType.Driver);
        }

        protected void SetBindRelations(PropertyBindings pb)
        {
            pb.AddRelation(this.lblAddress, "ADDRESS");
            pb.AddRelation(this.lblArchiveNo, "ARCHIVES_NO");
            pb.AddRelation(this.lblDriveNo, "DRIVE_NO");
            pb.AddRelation(this.lblDriveType, "DRIVE_KIND");
            pb.AddRelation(this.lblIdentity, "ID");

            pb.AddRelation(this.lblPhone, "PHONE");
            pb.AddRelation(this.lblUserName, "MAN_NAME");
            //pb.AddRelation(this.lblDept, "DEPT_CODE");
            //pb.AddRelation(this.lblChildDept, "CHILD_DEPT");
            //pb.AddRelation(this.lblEducation, "EDUCATION");
            //pb.AddRelation(this.lblJobKind, "JOB_KIND");

            //pb.AddRelation(this.ddlSex, "SEX");
            pb.AddRelation(this.lblBirthday, "BIRTH");
            pb.AddRelation(this.lblFirstDate, "DRIVE_FIRST");

        }
    }
}